/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author Cheng
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page, TreeDataModel } from '/@/api/model/baseModel';

const { adminPath } = useGlobSetting();

export interface DeviceInfo extends BasicModel<DeviceInfo> {
  name?: string; // 设备名称
  regionId?: string; // 所属区域ID
  regionName?: string; // 区域名称
  enterpriseId?: string; // 企业ID
  enterpriseName?: string; // 企业名称
  code?: string; // 设备编码
  ip?: string; // 设备IP地址
  addTime?: string; // 添加时间
  updateTime?: string; // 更新时间
  type?: string; // 设备类型
  warningTime?: number; // 给支队预警时间(单位：分钟)
  state?: string; // 设备状态（1:在线  0:离线）
  deleted?: string; // 软删除标志（FALSE: 未删除，TRUE: 已删除）
  dictValue?: string; // 设备类型字典值
  dictLabel?: string; // 设备类型字典标签
  appKey?: string; // 设备APPKEY
  token?: string; // 设备Token
}

export const deviceInfoList = (params?: DeviceInfo | any) =>
  defHttp.get<DeviceInfo>({ url: adminPath + '/security_alarm/deviceInfo/list', params });

export const deviceInfoListData = (params?: DeviceInfo | any) =>
  defHttp.post<Page<DeviceInfo>>({ url: adminPath + '/security_alarm/deviceInfo/listData', params });

export const deviceInfoForm = (params?: DeviceInfo | any) =>
  defHttp.get<DeviceInfo>({ url: adminPath + '/security_alarm/deviceInfo/form', params });

export const deviceInfoSave = (params?: any, data?: DeviceInfo | any) =>
  defHttp.postJson<DeviceInfo>({ url: adminPath + '/security_alarm/deviceInfo/save', params, data });

export const deviceInfoDelete = (params?: DeviceInfo | any) =>
  defHttp.get<DeviceInfo>({ url: adminPath + '/security_alarm/deviceInfo/delete', params });

export const deviceInfoTreeData = (params?: any) =>
  defHttp.get<TreeDataModel[]>({ url: adminPath + '/unitmanage/unitEnterpriseDominant/listData', params });

export const deviceInfoType = (params?: any) => {
  const defaultParams = {
    dictType: 'alarm_type',
    ...params
  };
  return defHttp.get({ url: adminPath + '/sys/dictData/listData', params: defaultParams });
};

export const deviceToken = (params?: any) =>
  defHttp.get<DeviceInfo>({ url: adminPath + '/security_alarm/deviceInfo/token', params });

